//using ELF.Gateway.Jwt;
//using Ocelot.DependencyInjection;
//using Ocelot.Middleware;
//using System.Text.Json;

//var builder = WebApplication.CreateBuilder(args);

//builder.AddServiceDefaults();

//// Add services to the container.

//// Ocelot Basic setup
//builder.Configuration
//    .SetBasePath(builder.Environment.ContentRootPath)
//    .AddOcelot(); // single ocelot.json file in read-only mode


//builder.Services.AddOcelot(builder.Configuration);

//builder.AddOpenIddictAuth();


//builder.Services.AddControllers();
//// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
//builder.Services.AddOpenApi();

//var app = builder.Build();

//app.MapDefaultEndpoints();

//// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
//    app.MapOpenApi();
//}

//app.UseFileServer();

//app.UseHttpsRedirection();

//// ��������������֤�м����������Ȩ��
//app.UseAuthentication();
//// Ȼ�������Զ��������м��
////app.UseMiddleware<GatewayMiddleware>();
//app.UseAuthorization();

//app.MapControllers();
//// ������Ocelot֮ǰע��

//await app.UseOcelot();

//app.Run();

using ELF;
using ELF.Modules;

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.AddDefaultCors();
await builder.AddModulesAsync<ElfGatewayModule>();
builder.Services.AddControllers();
var app = builder.Build();
app.UseRouting();
app.UseDefaultCors();
//app.UseMiddleware<ELF.Gateway.RequestResponseLoggingMiddleware>();
app.MapDefaultEndpoints();
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.UseFileServer();
await app.InitializeModulesAsync();
app.MapControllers();
await app.RunAsync();

